package com.fxsh168.server.activity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;

import com.fxsh168.server.R;
import com.fxsh168.server.base.BaseActivity;
import com.fxsh168.server.entitys.UserToday;
import com.fxsh168.server.interfaces.Constant;
import com.google.gson.Gson;

import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.List;

import okhttp3.Call;

public class IncomeActivity extends BaseActivity {

    private String token, mPhone;
    //    LinearLayout liMyYao;
    TextView teFen;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_income);
        SharedPreferences sp = getSharedPreferences(Constant.LOGINCLASS, MODE_PRIVATE);
//        liMyYao = (LinearLayout) findViewById(R.id.liMyYao);
        teFen = (TextView) findViewById(R.id.teFen);
        mPhone = sp.getString("mPhone", "");
        token = sp.getString("token", "");

        //跳转邀请界面
//        liMyYao.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                jumpActivity(MyYaoActivity.class);
//            }
//        });


        if (!TextUtils.isEmpty(token)) {
            getDistriBution();

        } else {
            jumpActivity(LoginActivity.class);
        }
    }


    //        司机今日返利
    public void getDistriBution() {
        OkHttpUtils.post().addParams("type", "2").addParams("phone", mPhone)
                .url(Constant.USERRETURN).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                Log.e("tag", "司机端今日返利数据" + response);
                UserToday userToday = new Gson().fromJson(response, UserToday.class);
                String code = userToday.getCode();
                if (code.equals(200 + "")) {
                    List<UserToday.DataBean> data = userToday.getData();
                    String fxfl = data.get(0).getFxfl();
                    teFen.setText(fxfl);
                }

            }
        });
    }


}
